package ie.timalb.chess.main.core.grid;

import java.util.HashMap;

public class Cells{
	private HashMap<CellId, Cell>  cells;
	private CellIdManager sequencer;
	
	public Cells() {
		setCells(new HashMap<CellId, Cell> ());
		setSequencer(new CellIdSequencialManager());
	}
	
	public Cell createNewCell (){
		CellId cellId = getSequencer().getNextCellId();
		Cell newCell = new Cell (this, cellId);
		this.getCells().put(cellId, newCell);
		return newCell;
	}

	public boolean contains(Cell toSearch) {
		return getCells().containsValue(toSearch);
	}

	public CellIterator getIterator(CellIteratorStrategy itStrategy) {
		return new CellIterator (this, itStrategy);
	}

	public Cell getCell(CellId cellId) {
		return getCells().get(cellId);
	}

	private HashMap<CellId, Cell> getCells() {
		return cells;
	}

	private void setCells(HashMap<CellId, Cell> cells) {
		this.cells = cells;
	}

	private CellIdManager getSequencer() {
		return sequencer;
	}

	private void setSequencer(CellIdManager sequencer) {
		this.sequencer = sequencer;
	}	
}
